package com.lg.head_first.chap02.observer.simple;

/**
 * @author by Mr. Li 2020/7/31 15:25
 */
public class SimpleObserver implements Observer {

    private int value;

    private Subject simpleSubject;

    public SimpleObserver(Subject simpleSubject) {
        this.simpleSubject = simpleSubject;
        simpleSubject.registerObserver(this);
    }

    @Override
    public void update(int value) {
        this.value = value;
        display();
    }

    private void display() {
        System.out.println("Value: " + value);
    }

}
